﻿using System;
using System.Collections.Generic;

using IDAL.AuthModel;
using Model.AuthModel;
using DALFactory.AuthModel;
namespace BLL.AuthModel
{
    /// <summary>
    /// 业务层，权限模型，操作记录
    /// </summary>
    public class StaffAccessBLL
    {
        private IStaffAccess dal = DataAccess.CreateStaffAccess();

        /// <summary>
        /// 新增登录记录
        /// </summary>
        /// <param name="staff"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        public bool InsertStaffAccess(StaffInfo staff, string ip,string desc)
        {
            StaffAccessInfo info = new StaffAccessInfo();
            info.Staff = staff;
            info.IP = ip;
            info.AccessDescription = desc;
            return dal.InsertStaffAccess(info);
        }

        /// <summary>
        /// 登录记录后台列表
        /// </summary>
        /// <param name="staffID"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public IList<StaffAccessInfo> BackList(int staffID, string key, int pageIndex, int pageSize, out int recordCount)
        {
            StaffAccessCondition condition = new StaffAccessCondition();
            condition.StaffID = staffID;
            condition.KeyWord = key;
            condition.PageIndex = pageIndex;
            condition.PageSize = pageSize;
            condition.OrderBy = "AddTime DESC";
            return dal.ListStaffAccess(condition, out recordCount);
        }
    }
}
